<template>
  <div class="b-container">
    <div>B组件</div>
    <div>
      count: {{ count }} <br />
      totalPrice: {{ totalPrice }}
      <button @click="incCount">count++</button>
    </div>
  </div>
</template>

<script setup>

// 导入仓库
import useCountStore from './store/module/count'
import { storeToRefs } from 'pinia'
// 创建仓库对象
const countStore = useCountStore()

// 解构仓库对象中的状态会丢失响应式，需要通过storeToRefs包装成一个ref对象，让其继续具备响应式
const { count, totalPrice } = storeToRefs(countStore)
// 方法直接解构
const { incCount } = countStore

</script>

<style>
.b-container {
  border: 5px solid #396a5f;
  padding: 3px;
  width: 300px;
  height: 300px;
  margin: 10px auto;
}
</style>